<template> 
  <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
        router 
      :collapse="isCollapse" 
      >
     <!-- 添加router属性 使得侧边栏可以导航 -->

      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>用户管理</span>
        </template>

        <el-menu-item-group>
          <el-menu-item index="/welcome">welcome</el-menu-item>
          <el-menu-item index="/user">user</el-menu-item>
          <el-menu-item index="1-3">选项3</el-menu-item>
        </el-menu-item-group>

      </el-submenu>

      <el-menu-item index="/shop">
        <i class="el-icon-menu"></i>
        <span slot="title">商品管理</span>
      </el-menu-item>

      <el-menu-item index="3" disabled>
        <i class="el-icon-document"></i>
        <span slot="title">导航三</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <span slot="title">导航四</span>
      </el-menu-item>

    </el-menu>
</template>

<script>
export default {
     methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
    },

    data() {
        return {
          //  isCollapse:false
        }
    },

    computed: {
      isCollapse() {
        console.log(this.$store.state.isCollapse);
       return this.$store.state.isCollapse
      }
    }
};
</script>

<style scoped lang='scss'>
.el-menu-vertical-demo {
    min-height: 300px;
    border: none;
}
</style>
